package com.net.xpay.common.manager.impl.sync;

import com.net.xpay.common.manager.sync.CommonSafePayBatchManager;
import com.net.common.dao.BasicMapper;
import com.net.common.dao.Page;
import com.net.common.manager.AbstractManager;
import com.net.xpay.common.dao.sync.CommonSafePayBatchMapper;
import com.net.xpay.common.domain.sync.CommonSafePayBatch;
import com.net.xpay.core.model.SafePayBatchSearchModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;


@Component
public class CommonSafePayBatchManagerImpl extends AbstractManager<CommonSafePayBatch> implements CommonSafePayBatchManager {

    @Autowired
    private CommonSafePayBatchMapper mapper;


    @Override
    protected BasicMapper<Long, CommonSafePayBatch> getMapper() {
        return mapper;
    }

    @Override
    public List<CommonSafePayBatch> search(SafePayBatchSearchModel searchModel) {
        Page page = new Page(searchModel);
        page.addOrder("id", "desc");
        return nonEmptyList(mapper.search(searchModel, page));
    }

    @Override
    public long searchCount(SafePayBatchSearchModel searchModel) {
        return mapper.searchCount(searchModel);
    }

    @Override
    public long statSafePayActivePartnerCount(LocalDateTime minEndTime, LocalDateTime maxEndTime) {

        return mapper.statSafePayActivePartnerCount(minEndTime, maxEndTime);
    }
}
